/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StudentDetail.java
 *
 * Created on 24-03-2012, 17:14:18
 */
package Management;

import ConnectData.Config;
import ConnectData.getConnections;
import Register.MyMD5;
import UploadData.Database;
import UploadData.Student;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;

/**
 *
 */
public class StudentDetail extends javax.swing.JFrame {

    private String UserName;
    private String Pass;
    private String RePass;
    private String fullName;
    private String phone;
    private String email;
    private String Address;
    private String Gender;
    private String Access;
    private int StuID = 0;
    private int rsCur = 0;
    AdminForm parent;
    private Vector vtStudent1;
    private Vector vtCourseRegister;
    private Vector vttem2;
    private Vector vttem3;
    private Vector vtCourseRegister2;
    private Vector vtCertificate;

    public StudentDetail(javax.swing.JFrame parent, int ID, int rscurr, String Access, String stuUserName, String stuPass) {
        try {
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        } catch (UnsupportedLookAndFeelException ue) {
        }
        initComponents();
        this.StuID = ID;
        this.rsCur = rscurr;
        this.Access = Access;
        this.UserName = stuUserName;
        this.Pass = stuPass;
        this.parent = (AdminForm) parent;
        initData();

        this.setVisible(true);
    }

    public void initData() {
        vtStudent1 = new Database().loadStudent(" where StuID=" + StuID);
        Vector vtStudent = (Vector) vtStudent1.get(0);
        txtUserName.setText(UserName);
        pwfPass.setText(Pass);
        txtFullName.setText(vtStudent.get(4).toString());
        Date birthday = (Date) (vtStudent.get(5));
        jdcBirthDate.setDate(birthday);
        String Gender = vtStudent.get(6).toString();
        if (Gender.trim().equals("0")) {
            chkFeMale.setSelected(true);
        } else if (Gender.equals("1")) {
            chkMale.setSelected(true);
        }
        txtPhone.setText(vtStudent.get(7).toString());
        txtEmail.setText(vtStudent.get(8).toString());
        txtAdd.setText(vtStudent.get(9).toString());
        String Status = vtStudent.get(3).toString();
        if (Status.trim().equals("0")) {
            chkDeny.setSelected(true);
        } else if (Status.equals("1")) {
            chkAllow.setSelected(true);
        }
        initCourse();
        initCourseRegister();
        initCertificate();
    }

    public void initCertificate() {
        Vector vtCol;
        vtCol = new Vector();
        String headline;
        headline = "Course Name";
        vtCol.add(headline);
        headline = "Start Date";
        vtCol.add(headline);
        headline = "End Date";
        vtCol.add(headline);
        headline = " Rate ";
        vtCol.add(headline);
        headline = "Degree Day";
        vtCol.add(headline);
        vtCertificate = new Database().loadvwCetificate(" where StuID=" + StuID);
        Vector vttem = new Vector();
        vttem3 = new Vector();
        for (int i = 0; i < vtCertificate.size(); i++) {
            vttem.add(((Vector) vtCertificate.get(i)).get(4));
            vttem.add(((Vector) vtCertificate.get(i)).get(5));
            vttem.add(((Vector) vtCertificate.get(i)).get(6));
            float Mark = Float.parseFloat(((Vector) vtCertificate.get(i)).get(7).toString());

            if (Mark >= 7.5) {
                vttem.add("Distinction");
            } else if (Mark >= 6 && Mark < 7.5) {
                vttem.add("A");
            } else if (Mark >= 5 && Mark < 6) {
                vttem.add("B");
            } else if (Mark >= 4 && Mark < 5) {
                vttem.add("C");
            }
            vttem.add(((Vector) vtCertificate.get(i)).get(8));
            vttem3.add(vttem);
            vttem = new Vector();
        }
        DefaultTableModel dtm = new DefaultTableModel(vttem3, vtCol);
        tbCertificate.setModel(dtm);
    }

    public void initCourseRegister() {
        Vector vtCol;
        vtCol = new Vector();
        String headline;
        headline = "Course Name";
        vtCol.add(headline);
        headline = "Start Date";
        vtCol.add(headline);
        headline = "End Date";
        vtCol.add(headline);
        headline = "Status";
        vtCol.add(headline);
        vtCourseRegister = new Database().loadCourseRegister(" where StuID=" + StuID);
        if (vtCourseRegister.size() > 0) {
            Vector vttem = new Vector();
            vttem2 = new Vector();
            for (int i = 0; i < vtCourseRegister.size(); i++) {
                String CourseName = "";
                String CourID = ((Vector) vtCourseRegister.get(i)).get(2).toString();
                if(CourID.equals("null"))
                {
                    CourID="0";
                }
                Vector vtCour = new Database().loadCourse(" where CourseID='" + CourID + "'");
                if (vtCour.size() > 0) {
                    String courID;
                    for (int j = 0; j < vtCour.size(); j++) {
                        courID = ((Vector) vtCour.get(j)).get(0).toString();
                        if (courID.equals(CourID)) {
                            CourseName = ((Vector) vtCour.get(j)).get(1).toString();
                        }
                    }
                }
                vttem.add(CourseName);
                vttem.add(((Vector) vtCourseRegister.get(i)).get(3));
                vttem.add(((Vector) vtCourseRegister.get(i)).get(4));
                String Status = ((Vector) vtCourseRegister.get(i)).get(5).toString();
                if (Status.equals("1")) {
                    vttem.add("Successful");
                } else {
                    vttem.add("Unsuccessful");
                }
                vttem2.add(vttem);
                vttem = new Vector();
            }
            DefaultTableModel dtm = new DefaultTableModel(vttem2, vtCol);
            tbEmp.setModel(dtm);
        }
    }

    public void initCourse() {
        Vector vtCour = new Database().loadCourse("");
        Vector vttem = new Vector();
        vttem.add("choose");
        if (vtCour.size() > 0) {
            for (int i = 0; i < vtCour.size(); i++) {
                vttem.add(((Vector) vtCour.get(i)).get(1).toString());
            }
        }
        DefaultComboBoxModel dcbm = new DefaultComboBoxModel(vttem);
        cbbCourse.setModel(dcbm);
    }

    public void tbClicked() {

        int rowcurrent = tbEmp.getSelectedRow();
        if (rowcurrent == -1) {
            rowcurrent = 0;
        }
        // vtCourseRegister2 = new Database().loadCourseRegister(" where StuID=" + StuID);
        Vector temp = new Vector();
        temp = (Vector) vttem2.get(rowcurrent);
        Date startdate = (Date) temp.get(1);
        jdcStartDate.setDate(startdate);
        Date enddate = (Date) (temp.get(2));
        jdcEndDate.setDate(enddate);

        cbbCourse.setSelectedItem(temp.get(0).toString());
    }

    public void CourseRegister() {
        boolean valid = validateInformationCourseRegister();
        if (valid) {

            Connection cn = new Config().cn;
            PreparedStatement pst = null;
            int CourID = 0;
            if ((!cbbCourse.getSelectedItem().toString().equals("choose")) || (!cbbCourse.getSelectedItem().toString().equals(""))) {
                Vector vtCour = new Database().loadCourse("");
                for (int i = 0; i < vtCour.size(); i++) {
                    if (cbbCourse.getSelectedItem().toString().equals(((Vector) vtCour.get(i)).get(1).toString())) {
                        CourID = Integer.parseInt(((Vector) vtCour.get(i)).get(0).toString());
                        break;
                    }
                }
                try {
                    String strUpdata = "insert into CourseRegister(StuID,CourseID,StartDate,EndDate)values(?,?,?,?)";
                    pst = cn.prepareCall(strUpdata);
                    pst.setInt(1, StuID);
                    pst.setInt(2, CourID);
                    Date StartDate = jdcStartDate.getDate();
                    SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
                    pst.setString(3, SDF.format(StartDate));
                    Date EndDate = jdcEndDate.getDate();
                    pst.setString(4, SDF.format(EndDate));
                    int kq = pst.executeUpdate();
                    if (kq != -1) {
                        JOptionPane.showMessageDialog(this, "Insert successful!");
                        btnInsertCourse.setText("Insert");
                        btnUpdateCours.setText("Update");
                        btnDelCourse.setVisible(true);
                        initCourseRegister();
                    } else {
                        JOptionPane.showMessageDialog(this, "Insert not avaiable!");
                    }
                } catch (Exception sQLException) {
                    sQLException.printStackTrace();
                } finally {
                    try {
                        getConnections.closeObject(pst);
                        getConnections.closeObject(cn);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                initCourseRegister();
                // } else {
                //     JOptionPane.showMessageDialog(this, "Course Registed");
                // }
            }
        }
    }

    public void updateCourseRegister() {
        boolean valid = validateInformationCourseRegister();
        if (valid) {

            Connection cn = new Config().cn;
            PreparedStatement pst = null;
            int CourID = 0;
            if ((!cbbCourse.getSelectedItem().toString().equals("choose")) || (!cbbCourse.getSelectedItem().toString().equals(""))) {
                Vector vtCour = new Database().loadCourse("");
                for (int i = 0; i < vtCour.size(); i++) {
                    if (cbbCourse.getSelectedItem().toString().equals(((Vector) vtCour.get(i)).get(1).toString())) {
                        CourID = Integer.parseInt(((Vector) vtCour.get(i)).get(0).toString());
                        break;
                    }
                }
            }
            String strUpdata = "update CourseRegister set StuID=?,CourseID=?,StartDate=?,EndDate=? where CRID=?";
            int rowcurrent = tbEmp.getSelectedRow();
            if (rowcurrent == -1) {
                JOptionPane.showMessageDialog(this, "Please select row that you want to update!");
            } else {
                Vector temp = new Vector();
                temp = (Vector) vtCourseRegister.get(rowcurrent);
                try {
                    pst = cn.prepareCall(strUpdata);
                    pst.setInt(1, StuID);
                    pst.setInt(2, CourID);
                    Date StartDate = jdcStartDate.getDate();
                    SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
                    pst.setString(3, SDF.format(StartDate));
                    Date EndDate = jdcEndDate.getDate();
                    pst.setString(4, SDF.format(EndDate));
                    pst.setInt(5, Integer.parseInt(temp.get(0).toString()));
                    int kq = pst.executeUpdate();
                    if (kq != -1) {
                        JOptionPane.showMessageDialog(this, "Update Course  successfull!");
                    } else {
                        JOptionPane.showMessageDialog(this, "Can't Update Data!");
                    }
                } catch (Exception sQLException) {
                    JOptionPane.showMessageDialog(this, "Data type of Start date or End date is incorrect!");
                    sQLException.printStackTrace();
                } finally {
                    try {
                        getConnections.closeObject(pst);
                        getConnections.closeObject(cn);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                initCourseRegister();
            }

        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        tabUpdate = new javax.swing.JTabbedPane();
        panAcademic = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbCertificate = new javax.swing.JTable();
        panEmploymentHis = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbEmp = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        btnInsertCourse = new javax.swing.JButton();
        btnUpdateCours = new javax.swing.JButton();
        btnDelCourse = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jdcStartDate = new com.toedter.calendar.JDateChooser();
        jdcEndDate = new com.toedter.calendar.JDateChooser();
        cbbCourse = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        panPrivate = new javax.swing.JPanel();
        txtFullName = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtAdd = new javax.swing.JTextField();
        btnUpdatePri = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        chkAllow = new javax.swing.JRadioButton();
        chkDeny = new javax.swing.JRadioButton();
        jdcBirthDate = new com.toedter.calendar.JDateChooser();
        jPanel3 = new javax.swing.JPanel();
        chkMale = new javax.swing.JRadioButton();
        chkFeMale = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        txtUserName = new javax.swing.JTextField();
        pwfPass = new javax.swing.JPasswordField();
        jLabel4 = new javax.swing.JLabel();
        btnSignOut = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        tabUpdate.setBackground(new java.awt.Color(204, 255, 204));

        panAcademic.setBackground(new java.awt.Color(204, 255, 204));

        tbCertificate.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbCertificate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbCertificateMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tbCertificate);

        javax.swing.GroupLayout panAcademicLayout = new javax.swing.GroupLayout(panAcademic);
        panAcademic.setLayout(panAcademicLayout);
        panAcademicLayout.setHorizontalGroup(
            panAcademicLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panAcademicLayout.createSequentialGroup()
                .addGap(83, 83, 83)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 488, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(167, Short.MAX_VALUE))
        );
        panAcademicLayout.setVerticalGroup(
            panAcademicLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panAcademicLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(208, Short.MAX_VALUE))
        );

        tabUpdate.addTab("Certificate", panAcademic);

        panEmploymentHis.setBackground(new java.awt.Color(204, 255, 204));

        jScrollPane1.setBackground(new java.awt.Color(204, 255, 204));
        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Course Register", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(0, 0, 51))); // NOI18N

        tbEmp.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbEmp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ontbEmpClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbEmp);

        jPanel2.setBackground(new java.awt.Color(204, 255, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Update Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(0, 0, 51))); // NOI18N

        btnInsertCourse.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnInsertCourse.setForeground(new java.awt.Color(0, 0, 51));
        btnInsertCourse.setText("Insert");
        btnInsertCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInsertCourseonInsertEmp(evt);
            }
        });

        btnUpdateCours.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnUpdateCours.setForeground(new java.awt.Color(0, 0, 51));
        btnUpdateCours.setText("Update");
        btnUpdateCours.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateCoursonChangeEmp(evt);
            }
        });

        btnDelCourse.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnDelCourse.setForeground(new java.awt.Color(0, 0, 51));
        btnDelCourse.setText("Delete");
        btnDelCourse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDelCourseActionPerformed(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setForeground(new java.awt.Color(0, 0, 51));
        jLabel15.setText("Course :");

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel18.setForeground(new java.awt.Color(0, 0, 51));
        jLabel18.setText("Start Date:");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel16.setForeground(new java.awt.Color(0, 0, 51));
        jLabel16.setText("End Date:");

        cbbCourse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose Course" }));

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jButton1.setForeground(new java.awt.Color(0, 0, 51));
        jButton1.setText("Detail");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(110, 110, 110)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbbCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(btnInsertCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(37, 37, 37)
                        .addComponent(btnUpdateCours, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43)
                        .addComponent(btnDelCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(jdcStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jdcEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16))))
                .addContainerGap(69, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel18)
                        .addComponent(jLabel16)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbbCourse, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                    .addComponent(jdcStartDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jdcEndDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnUpdateCours, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnInsertCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDelCourse, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(54, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panEmploymentHisLayout = new javax.swing.GroupLayout(panEmploymentHis);
        panEmploymentHis.setLayout(panEmploymentHisLayout);
        panEmploymentHisLayout.setHorizontalGroup(
            panEmploymentHisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panEmploymentHisLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panEmploymentHisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 688, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(505, 505, 505))
        );
        panEmploymentHisLayout.setVerticalGroup(
            panEmploymentHisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panEmploymentHisLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(72, Short.MAX_VALUE))
        );

        tabUpdate.addTab("CourseRegister", panEmploymentHis);

        panPrivate.setBackground(new java.awt.Color(204, 255, 204));

        txtFullName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFullNameActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setForeground(new java.awt.Color(0, 0, 51));
        jLabel1.setText("Full Name:");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setForeground(new java.awt.Color(0, 0, 51));
        jLabel2.setText("Date of Birth:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setForeground(new java.awt.Color(0, 0, 51));
        jLabel7.setText("Address :");

        txtPhone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPhoneActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setForeground(new java.awt.Color(0, 0, 51));
        jLabel5.setText("Phone:");

        txtEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtEmailActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setForeground(new java.awt.Color(0, 0, 51));
        jLabel6.setText("Email:");

        txtAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAddActionPerformed(evt);
            }
        });

        btnUpdatePri.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnUpdatePri.setForeground(new java.awt.Color(0, 0, 51));
        btnUpdatePri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/save.png"))); // NOI18N
        btnUpdatePri.setText("Update");
        btnUpdatePri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdatePrionUpdatePrivateInfo(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(0, 0, 51));

        chkAllow.setBackground(new java.awt.Color(204, 255, 204));
        buttonGroup2.add(chkAllow);
        chkAllow.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkAllow.setForeground(new java.awt.Color(0, 0, 51));
        chkAllow.setText("Allow");

        chkDeny.setBackground(new java.awt.Color(204, 255, 204));
        buttonGroup2.add(chkDeny);
        chkDeny.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkDeny.setForeground(new java.awt.Color(0, 0, 51));
        chkDeny.setText("Deny");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(62, Short.MAX_VALUE)
                .addComponent(chkAllow)
                .addGap(49, 49, 49)
                .addComponent(chkDeny)
                .addGap(79, 79, 79))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkAllow)
                .addComponent(chkDeny))
        );

        jPanel3.setBackground(new java.awt.Color(204, 255, 204));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Gender", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N
        jPanel3.setForeground(new java.awt.Color(0, 0, 51));

        chkMale.setBackground(new java.awt.Color(204, 255, 204));
        buttonGroup1.add(chkMale);
        chkMale.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkMale.setForeground(new java.awt.Color(0, 0, 51));
        chkMale.setText("Male");

        chkFeMale.setBackground(new java.awt.Color(204, 255, 204));
        buttonGroup1.add(chkFeMale);
        chkFeMale.setFont(new java.awt.Font("Tahoma", 1, 11));
        chkFeMale.setForeground(new java.awt.Color(0, 0, 51));
        chkFeMale.setText("FeMale");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(62, Short.MAX_VALUE)
                .addComponent(chkMale)
                .addGap(49, 49, 49)
                .addComponent(chkFeMale)
                .addGap(79, 79, 79))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(chkMale)
                .addComponent(chkFeMale))
        );

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setForeground(new java.awt.Color(0, 0, 51));
        jLabel3.setText("Username :");

        txtUserName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtUserNameActionPerformed(evt);
            }
        });

        pwfPass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pwfPassActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setForeground(new java.awt.Color(0, 0, 51));
        jLabel4.setText("Password :");

        javax.swing.GroupLayout panPrivateLayout = new javax.swing.GroupLayout(panPrivate);
        panPrivate.setLayout(panPrivateLayout);
        panPrivateLayout.setHorizontalGroup(
            panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panPrivateLayout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addComponent(jLabel7)
                            .addGap(31, 31, 31)
                            .addComponent(txtAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE))
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addGap(83, 83, 83)
                            .addComponent(btnUpdatePri))
                        .addGroup(panPrivateLayout.createSequentialGroup()
                            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5)
                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel1)
                                .addComponent(jLabel4)
                                .addComponent(jLabel3))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtUserName)
                                .addComponent(txtPhone)
                                .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)
                                .addComponent(txtFullName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                                .addComponent(jdcBirthDate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(pwfPass)))))
                .addContainerGap(304, Short.MAX_VALUE))
            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panPrivateLayout.createSequentialGroup()
                    .addGap(106, 106, 106)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(312, Short.MAX_VALUE)))
        );
        panPrivateLayout.setVerticalGroup(
            panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panPrivateLayout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(pwfPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFullName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jdcBirthDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(106, 106, 106)
                .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addComponent(btnUpdatePri, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28))
            .addGroup(panPrivateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panPrivateLayout.createSequentialGroup()
                    .addContainerGap(246, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(212, 212, 212)))
        );

        tabUpdate.addTab("Private Informations", panPrivate);

        btnSignOut.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnSignOut.setForeground(new java.awt.Color(0, 0, 51));
        btnSignOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/close1.png"))); // NOI18N
        btnSignOut.setText("Exit");
        btnSignOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSignOutonSignOut(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tabUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 743, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(623, Short.MAX_VALUE)
                .addComponent(btnSignOut)
                .addGap(53, 53, 53))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnSignOut, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tabUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnUpdatePrionUpdatePrivateInfo(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdatePrionUpdatePrivateInfo
        // TODO add your handling code here:
        boolean valid = validateInformation();
        if (valid) {
            boolean Gender;
            if (chkMale.isSelected()) {
                Gender = false;
            } else {
                Gender = true;
            }
            int Status;
            if (chkAllow.isSelected()) {
                Status = 1;
            } else {
                Status = 0;
            }
            Student stu = new Student();
            stu.setStatus(Status);
            stu.setStuName(txtFullName.getText());
            Date birthday = jdcBirthDate.getDate();
            SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
            stu.setStuBirthDay(SDF.format(birthday));
            stu.setStuGender(Gender);
            stu.setStuPhone(txtPhone.getText());
            stu.setStuEmail(txtEmail.getText());
            stu.setStuAddress(txtAdd.getText());
            stu.setStuID(StuID);
            if (!txtUserName.equals(UserName)) {
                Vector vtSymp = new Database().loadStudents(" where UserName='" + txtUserName.getText() + "'");
                if (vtSymp.size() <= 0) {
                    stu.setUserName(txtUserName.getText());
                } else {
                    stu.setUserName(UserName);
                }

            }
            if (!pwfPass.getText().equals(Pass)) {
                stu.setStuPassword(MyMD5.getMD5String(pwfPass.getText()));
            } else {
                stu.setStuPassword(Pass);
            }
            int k = new Database().UpdateStudent(stu);


            if (k != -1) {
                JOptionPane.showMessageDialog(this, "Update successful!");
                parent.loadStudents();
            }


        }
}//GEN-LAST:event_btnUpdatePrionUpdatePrivateInfo

    private void tbCertificateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbCertificateMouseClicked
        // TODO add your handling code here:
}//GEN-LAST:event_tbCertificateMouseClicked

    private void ontbEmpClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ontbEmpClicked
        // TODO add your handling code here:
        tbClicked();
}//GEN-LAST:event_ontbEmpClicked

    private void btnInsertCourseonInsertEmp(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertCourseonInsertEmp
        // TODO add your handling code here:

        if (btnInsertCourse.getText().equals("Insert")) {
            btnInsertCourse.setText("Save");
            btnUpdateCours.setText("Cancel");
            btnDelCourse.setVisible(false);
            Date d = new Date();
            jdcStartDate.setDate(d);
            jdcEndDate.setDate(d);
            cbbCourse.setSelectedIndex(0);
        } else {
            CourseRegister();
        }

}//GEN-LAST:event_btnInsertCourseonInsertEmp

    private void btnUpdateCoursonChangeEmp(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateCoursonChangeEmp
        // TODO add your handling code here:

        if (btnUpdateCours.getText().equals("Update")) {
            updateCourseRegister();

        } else {
            btnUpdateCours.setText("Update");
            btnInsertCourse.setText("Insert");
            btnDelCourse.setVisible(true);


        }

}//GEN-LAST:event_btnUpdateCoursonChangeEmp

    private void btnDelCourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDelCourseActionPerformed
        // TODO add your handling code here:

        int rowcur = tbEmp.getSelectedRow();
        if (rowcur == -1) {
            JOptionPane.showMessageDialog(this, "Please select row that you want to delete!");
        } else {
            if (JOptionPane.showConfirmDialog(this, "Are you sure you want to Delete this row?") == 0) {
                int id = Integer.parseInt(((Vector) vtCourseRegister.get(rowcur)).get(0).toString());
                String strDel = "delete CourseRegister where CRID=?";
                Connection cn = new Config().cn;
                PreparedStatement pst = null;
                try {
                    pst = cn.prepareCall(strDel);
                    pst.setInt(1, id);
                    int kq = pst.executeUpdate();
                    if (kq != -1) {
                        JOptionPane.showMessageDialog(this, "Delete successful!");
                        initCourseRegister();
                    }
                } catch (SQLException ex) {
                    ex.printStackTrace();
                    JOptionPane.showConfirmDialog(this, "you can not delete Course Register  this");
                } finally {
                    try {
                        getConnections.closeObject(pst);
                        getConnections.closeObject(cn);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }

    }//GEN-LAST:event_btnDelCourseActionPerformed

    private void btnSignOutonSignOut(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSignOutonSignOut
        // TODO add your handling code here:

        int yes = JOptionPane.showConfirmDialog(this, "Are you sure you want to Exit?", "Exit confirm", JOptionPane.YES_NO_OPTION);


        if (yes == 0) {
            this.dispose();


        }

}//GEN-LAST:event_btnSignOutonSignOut

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int rscurrent = tbEmp.getSelectedRow();
        if (rscurrent >= 0) {
            int CRID = Integer.parseInt(((Vector) vtCourseRegister.get(rscurrent)).get(0).toString());
            int CourID = Integer.parseInt(((Vector) vtCourseRegister.get(rscurrent)).get(2).toString());
            new CourseDetail(CRID, StuID, CourID, Access);

        } else {
            JOptionPane.showMessageDialog(this, "Please Select Course do you want Watch Detail!");
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void txtUserNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtUserNameActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        pwfPass.requestFocus();
}//GEN-LAST:event_txtUserNameActionPerformed

    private void pwfPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pwfPassActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        txtFullName.requestFocus();
}//GEN-LAST:event_pwfPassActionPerformed

    private void txtFullNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFullNameActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        jdcBirthDate.requestFocus();
    }//GEN-LAST:event_txtFullNameActionPerformed

    private void txtPhoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPhoneActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        txtEmail.requestFocus();
    }//GEN-LAST:event_txtPhoneActionPerformed

    private void txtEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEmailActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        chkMale.requestFocus();
    }//GEN-LAST:event_txtEmailActionPerformed

    private void txtAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtAddActionPerformed
        // TODO add your handling code here:
        btnUpdatePrionUpdatePrivateInfo(evt);
        chkAllow.requestFocus();
    }//GEN-LAST:event_txtAddActionPerformed

    public boolean validateInformation() {
        String userName = txtUserName.getText();
        if (userName.equals("")) {
            JOptionPane.showMessageDialog(this, "You must input User name!");
            txtUserName.requestFocus();
            return false;
        } else if (!userName.equals(UserName)) {
            Vector vtUser = new Database().loadUsers(" where UserName='" + UserName + "' ORDER BY UserName");
            if (vtUser.size() != 0) {
                JOptionPane.showMessageDialog(this, "This user name is already exist!");
                vtUser.removeAllElements();
                txtUserName.setText("");
                txtUserName.requestFocus();
                return false;
            }

            if (userName.length() < 4) {
                JOptionPane.showMessageDialog(this, "length User name >= 4 character!");
                txtUserName.requestFocus();
                return false;
            }
        }
        String pass = pwfPass.getText();
        if (pass.equals("")) {
            JOptionPane.showMessageDialog(this, "You must input Password!");
            pwfPass.requestFocus();
            return false;
        }
        if (!pass.equals(Pass)) {
            if (pass.length() < 6) {
                JOptionPane.showMessageDialog(this, "length Password > 6 character!");
                pwfPass.requestFocus();
                return false;
            }
        }
        fullName = txtFullName.getText();
        if (fullName.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Student name!");
            txtFullName.requestFocus();
            return false;
        }
        phone = txtPhone.getText();
        if (phone.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Phone!");
            txtPhone.requestFocus();
            return false;
        } else {
            String phoneRegex = "[0-9]+";
            Pattern p = Pattern.compile(phoneRegex);
            Matcher m = p.matcher(phone);
            if (!m.matches()) {
                JOptionPane.showMessageDialog(this, "Phone is incorrect!");
                txtPhone.requestFocus();
                txtPhone.selectAll();
                return false;
            }
        }
        Date Birthday = jdcBirthDate.getDate();
        if (Birthday == null) {
            JOptionPane.showMessageDialog(this, "Birthday must not empty!", "Notify Message", JOptionPane.INFORMATION_MESSAGE);
            jdcBirthDate.requestFocus();
            return false;
        }
        Date d = new Date();
        if (Birthday != null) {
            if (jdcBirthDate.getCalendar().getTime().after(d)) {
                JOptionPane.showMessageDialog(this, "Birthday must be less than today!", "Notify Message", JOptionPane.INFORMATION_MESSAGE);
                jdcBirthDate.setDate(null);
                jdcBirthDate.requestFocus();
                return false;
            }
        }

        email = txtEmail.getText().trim();
        if (email.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your email");
            txtEmail.requestFocus();
            return false;
        } else {
            String emailRegex = "[a-zA-Z_]+[a-zA-Z0-9_]*@([a-zA-Z]+\\.)+[a-zA-Z]+";
            Pattern p = Pattern.compile(emailRegex);
            Matcher m = p.matcher(email);
            if (!m.matches()) {
                JOptionPane.showMessageDialog(this, "Email is incorrect!");
                txtEmail.requestFocus();
                txtEmail.selectAll();
                return false;
            }
        }
        Address = txtAdd.getText();
        if (Address.equals("")) {
            JOptionPane.showMessageDialog(this, "you must input your Student Address!");
            txtAdd.requestFocus();
            return false;
        }
        return true;
    }

    public boolean validateInformationCourseRegister() {
        Date startDate = jdcStartDate.getDate();
        Date endDate = (Date) jdcEndDate.getDate();
        if (endDate != null) {
            if (jdcEndDate.getDate().before(startDate)) {
                JOptionPane.showMessageDialog(this, "Startdate must be less than EndDate!", "Notify Message", JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
        }
        String course = cbbCourse.getSelectedItem().toString();
        if (course.equals("choose")) {
            JOptionPane.showMessageDialog(this, "you must choose Course!");
            cbbCourse.requestFocus();
            return false;
        }
        return true;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDelCourse;
    private javax.swing.JButton btnInsertCourse;
    private javax.swing.JButton btnSignOut;
    private javax.swing.JButton btnUpdateCours;
    private javax.swing.JButton btnUpdatePri;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JComboBox cbbCourse;
    private javax.swing.JRadioButton chkAllow;
    private javax.swing.JRadioButton chkDeny;
    private javax.swing.JRadioButton chkFeMale;
    private javax.swing.JRadioButton chkMale;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private com.toedter.calendar.JDateChooser jdcBirthDate;
    private com.toedter.calendar.JDateChooser jdcEndDate;
    private com.toedter.calendar.JDateChooser jdcStartDate;
    private javax.swing.JPanel panAcademic;
    private javax.swing.JPanel panEmploymentHis;
    private javax.swing.JPanel panPrivate;
    private javax.swing.JPasswordField pwfPass;
    private javax.swing.JTabbedPane tabUpdate;
    private javax.swing.JTable tbCertificate;
    private javax.swing.JTable tbEmp;
    private javax.swing.JTextField txtAdd;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtFullName;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtUserName;
    // End of variables declaration//GEN-END:variables
}
